<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('出库明细列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" id="json" name="json">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>仓库名称：</label>
                                <input type="text" name="deptName"/>
                            </li>
                            <li>
                                <label>出库编号：</label>
                                <input type="text" name="inputCode"/>
                            </li>
                            <li>
                                <label>物品名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>规格型号：</label>
                                <input type="text" name="model"/>
                            </li>

                            <li>
                                <label>出库时间：</label>
                                <input type="text" class="time-input" placeholder="请选择入库开始时间" name="startDate"/>-
                                <input type="text" class="time-input" placeholder="请选择入库结束时间" name="endDate"/>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('wms:outitem:edit')}]];
        var removeFlag = [[${@permission.hasPermi('wms:outitem:remove')}]];
        var typeDatas = [[${@dict.getType('wl_type')}]];
        var unitDatas = [[${@dict.getType('wl_unit')}]];
        var statusDatas = [[${@dict.getType('check_status')}]];
        var prefix = ctx + "wms/outitem";

        $(function() {
            var options = {
                url: prefix + "/list?status=1",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                onCheck: onCheck,
                onUncheck: onUncheck,
                onCheckAll: onCheckAll,
                onUncheckAll: onUncheckAll,
                modalName: "出库明细",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '部门id',
                    visible: false
                },
                {
                    field: 'deptName',
                    title: '仓库名称'
                },
                    {
                        field: 'inputCode',
                        title: '出库编号'
                    },
                {
                    field: 'code',
                    title: '物品编号'
                },
                {
                    field: 'name',
                    title: '物品名称'
                },
                {
                    field: 'model',
                    title: '规格型号'
                },
                {
                    field: 'type',
                    title: '类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    field: 'unit',
                    title: '单位',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(unitDatas, value);
                    }
                },

                /*{
                    field: 'totalQuantity',
                    title: '总库存数量'
                },
                {
                    field: 'repairQuantity',
                    title: '修复数量'
                },
                {
                    field: 'outRepairQuantity',
                    title: '出库报修数量'
                },*/
                {
                    field: 'outQuantity',
                    title: '出库数量'
                },
                    {
                        field: 'inQuantity',
                        title: '已入库数量'
                    },
                {
                    field: 'outTime',
                    title: '出库时间'
                }/*,
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }*/]
            };
            $.table.init(options);
        });


        var arr = new Array();
        function onCheck(row, $element){
            arr.push(row);
            $("#json").val(JSON.stringify(arr).toString());
        }

        function onUncheck(row, $element){
            ar.remove(row)
            $("#json").val(JSON.stringify(arr).toString());
        }

        function onCheckAll(rowsAfter, rowsBefore){
            arr = new Array();
            var rows = $.map(rowsAfter, function(row) {
                arr.push(row);
            });

            $("#json").val(JSON.stringify(arr).toString());
        }

        function onUncheckAll(rowsAfter, rowsBefore){
            arr = new Array();
            $("#json").val("");
        }
        Array.prototype.remove=function (val) {
            var index = this.indexOf(val);
            if(index >-1){
                this.splice(index,1)
            }
        }
    </script>
</body>
</html>